package com.ctcemti.mdm.project.sys.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.handler.inter.IExcelDataModel;
import cn.afterturn.easypoi.handler.inter.IExcelModel;
import com.ctcemti.mdm.project.sys.entity.formdata.BaseReq;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Id;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@ApiModel(value = "项目人员表")
@JsonIgnoreProperties(value={"handler"})//是json序列化时忽略bean中的一些属性序列化和反序列化时抛出的异常.
public class OrgPerson extends BaseReq implements IExcelModel,IExcelDataModel,Comparable<OrgPerson>,Serializable{

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    @Id
    private String id;

    @ApiModelProperty(value = "编号")
    private String code;

    @ApiModelProperty(value = "姓名")
    @Excel(name = "姓名")
    @NotNull(message = "姓名不能为空")
    private String name;

    @ApiModelProperty(value = "登录名")
    @Excel(name = "登录名")
    @NotNull(message = "登录名不能为空")
    private String loginName;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "性别")
    @Excel(name = "性别")
    private String sexy;

    @ApiModelProperty(value = "职位")
    @Excel(name = "职位")
    private String title;

    @ApiModelProperty(value = "排序")
    @Excel(name = "排序")
    private Integer sort;

    @ApiModelProperty(value = "用户类型")
    @Excel(name = "用户类型")
    private String type;

    @ApiModelProperty(value = "用户状态")
    @Excel(name = "用户状态")
    private String state;

    @ApiModelProperty(value = "身份证")
    @Excel(name = "身份证")
    @Pattern(regexp = "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$",message = "身份证格式不正确")
    private String idCard;

    @ApiModelProperty(value = "手机号")
    @Excel(name = "手机号")
    @Pattern(regexp = "^1\\d{10}$",message = "手机号格式不正确")
    private String phone;

    @ApiModelProperty(value = "邮箱")
    @Excel(name = "邮箱")
    @Pattern(regexp = "^[A-Za-z0-9\\u4e00-\\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",message = "邮箱格式不正确")
    private String email;

    @ApiModelProperty(value = "照片")
    private String image;

    @ApiModelProperty(value = "备注")
    private String comment;

    @ApiModelProperty(value = "创建人")
    private String creator;

    @ApiModelProperty(value = "创建时间")
    private Date createDate;

    @ApiModelProperty(value = "修改人")
    private String modifiedBy;

    @ApiModelProperty(value = "修改时间")
    private Date modifyDate;


    @Transient
    private List<OrgRole> roleList;


    @Transient
    private String orgId;

    @Transient
    private String orgName;

    @Transient
    private String roleId;

    @Transient
    private String roleName;

    @Transient
    @ApiModelProperty(hidden = true)//swagger忽略属性
    private int rowNum;

    @Transient
    @Excel(name = "错误提示")
    @ApiModelProperty(hidden = true)//swagger忽略属性
    private String errorMsg;

    @Override
    public int compareTo(OrgPerson orgPerson) {           //重写Comparable接口的compareTo方法，
        return this.rowNum - orgPerson.getRowNum();// 根据行号升序排列，降序修改相减顺序即可
    }


}
